
public class UIActions {
	public static void radialAction(int i) {
		
	}
	public static void graphAction(int i) {
		if (Main.graphs[i].label.equals("graph")) {
			System.out.println("GRAPH ME");
		}
		if (Main.graphs[i].label.equals("human")) {
			double value = 1. - Main.graphs[i]._y/(float)Main.graphs[i].h;
			System.out.println("value = "+value);
		}
		if (Main.graphs[i].label.equals("set graphs")) {
			float[] newValues = {Main.graphs[i]._x/ (float)(Main.graphs[i].w),Main.graphs[i]._y/(float)Main.graphs[i].h};
			System.out.println("newValue: "+newValues[0]+" "+newValues[1]);
			setGraph(newValues,"default");
		}
	}
	public static void buttonAction(int i) {

		if (Main.buttons[i].label.equals("human")) {
			if (Main.buttons[i].on || Main.buttons[i].pressing) {
				Main.humanPlaying = true;
			}
		}
		if (Main.buttons[i].label.equals("play")) {
			if (Main.buttons[i].on || Main.buttons[i].pressing) {
				Main.playing = true;
			}
		}
		
		if (Main.buttons[i].label.equals("sync")) {
			if (Main.buttons[i].pressing) {
				System.out.println("running sync");
				Sync sync = new Sync();
				try {
					sync.run();
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}
	}
	public static void setToggle(boolean on, String label) {
		for (int i=0;i<Main.buttons.length;i++) {
			if (Main.buttons[i].label.equals(label)) {
				Main.buttons[i].on=on;
			}
		}
	}
	public static void setGraph(float[] coord, String label) {
		for (int i=0;i<Main.graphs.length;i++) {
			if (Main.graphs[i].label.equals(label)) {
				Main.graphs[i]._x=(int) (coord[0]*Main.graphs[i].w);
				Main.graphs[i]._y=(int) (coord[1]*Main.graphs[i].h);
			}
		}
	}
	
	public static void setButton(boolean on, String label) {
		for (int i=0;i<Main.buttons.length;i++) {
			if (Main.buttons[i].label.equals(label)) {
				Main.buttons[i].on=on;
			}
		}
	}
	public static void setLabel(String newLabel, String label) {
		for (int i=0;i<Main.buttons.length;i++) {
			if (Main.buttons[i].label.equals(label)) {
				Main.buttons[i].label=newLabel;
			}
		}
		for (int i=0;i<Main.graphs.length;i++) {
			if (Main.graphs[i].label.equals(label)) {
				Main.graphs[i].label=newLabel;
			}
		}
	}
}
